package com.cloud.lan.entity.enums;

import cn.hutool.core.text.CharSequenceUtil;

/**
 * 统一RedisKey枚举
 * @author ErKang
 * @date Created in 2021/12/28 23:35
 * @title RedisKeyEnum.java
 * Department: Product development
 */
public enum RedisKeyEnum {

    /** 微信公众号平台accessToken */
    WX_API_ACCESS_TOKEN("lan:user:WX_API_ACCESS_TOKEN:{}"),
    /** 微信公众号平台accessToken-redis锁 */
    WX_API_ACCESS_TOKEN_LOCK("litta:user:WX_API_ACCESS_TOKEN_LOCK:{}"),
    /** 微信公众号平台accessToken流控 */
    WX_API_ACCESS_TOKEN_LIMIT("litta:user:WX_API_ACCESS_TOKEN_LIMIT:{}"),
    /** 下单保存对象 */
    SMS_CODE("lan:user:sms:SMS_CODE:{}"),
    IMG_CODE("lan:user:img:IMG_CODE:{}"),
    CREATE_ORDER_CALLBACK("lan:order:CREATE_ORDER_CALLBACK:{}"),
    /** 用于保存微信统计数据 */
    WX_DATA_METHOD("lan:wx:data:WX_DATA_METHOD:{}"),
    ;

    private final String format;

    RedisKeyEnum(String format) {
        this.format = format;
    }

    /**
     * 获取Redis键
     * @param objs 占位参数
     * @return key
     */
    public String key(Object... objs) {
        return CharSequenceUtil.format(format, objs);
    }
}
